package city.spring.modules.work.vo;

import city.spring.modules.work.action.model.AbstractPlanUser;
import city.spring.modules.work.entity.WorkPlanUserExtEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * @author HouKunLin
 * @date 2020/6/4 0004 16:48
 * @see WorkPlanUserExtEntity
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class WorkPlanUserVO extends WorkPlanUserExtEntity {
    /**
     * 人员名称
     */
    private String nickname;

    /**
     * 转换成排班时所需要的对象
     *
     * @return AbstractPlanUser
     */
    public AbstractPlanUser<WorkPlanUserVO> toPlanUser() {
        WorkPlanUserVO item = this;
        return new AbstractPlanUser<WorkPlanUserVO>() {

            @Override
            public Object getKey() {
                return item.getUserId();
            }

            @Override
            public String getTitle() {
                return item.getNickname();
            }

            @Override
            public int getWorkNumber() {
                return item.getWorkNumber();
            }

            @Override
            public WorkPlanUserVO getObject() {
                return item;
            }
        };
    }
}
